package com.batsoft.trade.model;

import com.batsoft.trade.model.transaction.Cycle;

/**
 * @author <a href="mailto:hellohesir@gmail.com">Mr_He</a>
 * 2019/8/19 17:56
 */
public class RedisKey {

    /**
     * 撮合的订单
     */
    private static final String ORDER_WAIT_ORDER = ":WAIT_ORDER:";
    private static final String MATCH_SUCCESS_ORDER = ":SUCCESS_ORDER:";
    private static final String MATCH_ERROR_ORDER = ":ERROR_ORDER:";

    public static String getOrderWaitOrder(Cycle cycle, String coinCode) {
        return coinCode + ORDER_WAIT_ORDER + cycle.getCycle();
    }

    public static String getMatchSuccessOrder(Cycle cycle, String coinCode) {
        return coinCode + MATCH_SUCCESS_ORDER + cycle.getCycle();
    }

    public static String getMatchErrorOrder(Cycle cycle, String coinCode) {
        return coinCode + MATCH_ERROR_ORDER + cycle.getCycle();
    }

    /**
     * 等待撮合订单
     */
    private static final String MATCH_WAIT_BUY = ":WAIT_BUY:";
    private static final String MATCH_WAIT_SELL = ":WAIT_SELL:";

    public static String getMatchWaitBuyOrder(Cycle cycle, String coinCode) {
        return coinCode + MATCH_WAIT_BUY + cycle.getCycle();
    }

    public static String getMatchWaitSellOrder(Cycle cycle, String coinCode) {
        return coinCode + MATCH_WAIT_SELL + cycle.getCycle();
    }

    /**
     * =======================================================================
     */
    // 市价
    public static String getMarketPrice(String coinCode) {
        return coinCode + ":MARKET_PRICE";
    }

    /**
     * =============================合约相关==========================================
     */
    // 持仓 hash
    public static String getPosition(Cycle cycle, String coinCode) {
        return coinCode + ":POSITION:" + cycle.getCycle();
    }

}
